﻿using T4UtilityBelt.DataDesigns;
using T4UtilityBelt.Writers;

namespace T4UtilityBelt.UxDesigns.Controls.Renderers.Windows
{
    public class ParentManyRenderer : ParentRenderer<ParentManyControl, IParentManyRenderer, ParentMany>, IParentManyRenderer
    {
        protected override void OnRenderUiXmlContentInput(ParentManyControl control, CodeWriter writer)
        {
            //<ListBox Controls:HelpText.Text="<#=name#>tt" DataContext="{Binding}"
            //						 ItemsSource="{Binding <#=toEntity#>List}"
            //                        DisplayMemberPath="Title"
            //                         SelectedValuePath="Id"
            //                         SelectionMode="Multiple">
            //                    <i:Interaction.Behaviors>
            //                        <i:MultiSelectBehavior SelectedItems="{Binding Entry.<#=name#>, Mode=TwoWay}">
            //                        </i:MultiSelectBehavior>
            //                    </i:Interaction.Behaviors>
            //                </ListBox>
            //writer.WriteBeginTag("ComboBox");
            //writer.WriteAttribute("Controls:HelpText.Text", control.HelpText);
            //writer.WriteAttribute("ItemsSource", string.Format(@"{{Binding {0}List}}", control.Property.ToEntity));
            //writer.WriteAttribute("DisplayMemberPath", "Title");
            //writer.WriteAttribute("SelectedValuePath", "Id");
            //writer.WriteAttribute("SelectedValue", string.Format(@"{{Binding {0},  Mode=TwoWay}}", GetBindingContext(control)));

            //writer.WriteFullEnd();
        }

        protected override void OnRenderUiXmlContentReadOnly(ParentManyControl control, CodeWriter writer)
        {
            //<TextBlock    Text="{Binding  Entry.<#=name#>, Converter={StaticResource iModelText}}" />
            writer.WriteBeginTag("TextBlock");
            RenderControlAttributes(control, writer);
            //writer.WriteAttribute("Text", string.Format(@"{{Binding {0}, Converter={{StaticResource iModelsText}}}}", GetBindingContext(control)));

            writer.WriteFullEnd();
        }

        protected override void OnRenderViewModelCs(ParentManyControl control, CodeWriter writer)
        {
            writer.WriteFormatLine(
@"      public {0}Collection {0}List
        {
            get
            {
                return {0}Pickers.Items().Result;
            }
        }
",
            control.Property.ToName
);
        }
    }
}